<template>
  <view class="content">

    <view v-if="dataList.length!=0 && dataListtwo.length!=0">
      <view v-for="(item,index) in dataList" :key="index" @click="jump_page(item,index)">
        <!-- {{ item.name  }} -->
        <!-- 主体 -->
        <view class="head_body">
          <view class="img_view">
            <!--  -->
            <!-- 'https://test.bowu66.com/' -->
            <img :src=" IMG_URL  +   item.thumb" alt="">
          </view>
          <view :class="item.states == 1 ? 'flort2': item.states == 2 ?'flort' : item.states == 3 ?'flort1':''  ">
            {{ item.states == 3 ? '报名已结束': item.states == 2 ?'报名进行中' : item.states == 1 ?'报名未开始':''   }}
          </view>
          <view class="name">
            {{ item.activityName }}
          </view>
          <view class="dataTime">
            {{ item.activityStartDate }} / {{ item.activityEndDate }}
          </view>
        </view>

      </view>
      <view v-for="(item,index) in dataListtwo" :key="index" @click="jump_page1(item,index)">
        <view class="head_body">
          <view class="img_view">
            <img :src="IMG_URL + item.thumb" alt="">
          </view>
          <!-- <view :class="item.state == 1 ? 'flort': item.state == 2 ?'flort1' : item.state == 3 ?'flort2':''  ">
          {{ item.state == 1 ? '报名进行中': item.state == 2 ?'报名已结束' : item.state == 3 ?'报名未开始':''   }}
        </view> -->
          <view class="name">
            {{ item.name }}
          </view>
          <view class="dataTime">
            {{ item.info }}
          </view>
        </view>

      </view>
    </view>
    <view v-else class="dis_none">
      暂时没有数据
    </view>

  </view>
</template>

<script>
  import {
    IMG_URL
  } from "../../env.js"


  import {
    getHomeActivity
  } from '@/common/request/api.js'

  export default {
    data() {
      return {
        title: 'Hello',
        dataList: [],
        IMG_URL,
        dataListtwo: []
      }
    },
    onLoad() {
      this.getHomeActivity()
    },
    onShow() {
      this.getHomeActivity()

    },
    methods: {
      // 跳转详情页
      jump_page(a, b) {
        console.log(a, b);
        uni.navigateTo({
          url: '../ActivityDetail/index?id=' + a.id
        });
      },
      //跳转列表页
      jump_page1(a, b) {
        console.log(a, b);
        uni.navigateTo({
          url: '../Activitylist/index?id=' + a.id
        });
      },
      getHomeActivity() {
        getHomeActivity().then(res => {
          console.log(res.data.data.activityLists)
          if (res.data.code == 200) {
            this.dataList = res.data.data.activityLists
            this.dataListtwo = res.data.data.groupLists
            console.log(this.dataList);
            console.log(this.dataListtwo);
          }
        })
      }
    }
  }
</script>

<style lang="less" scoped src="./index.less">


</style>